package com.gupao.javavip.dubbo.sentinel.server;

import com.alibaba.csp.sentinel.cluster.server.ClusterTokenServer;
import com.alibaba.csp.sentinel.cluster.server.SentinelDefaultTokenServer;
import com.alibaba.csp.sentinel.cluster.server.config.ClusterServerConfigManager;
import com.alibaba.csp.sentinel.cluster.server.config.ServerTransportConfig;
import lombok.extern.apachecommons.CommonsLog;

import java.util.Collections;

@CommonsLog
public class DubboClusterTokenServer {
    public static void main(String[] args) {
        try {
            ClusterTokenServer tokenServer = new SentinelDefaultTokenServer();
            ClusterServerConfigManager.loadGlobalTransportConfig(new
                    ServerTransportConfig().
                    setIdleSeconds(600).setPort(9999));
            ClusterServerConfigManager.loadServerNamespaceSet(Collections.singleton("AppMic"));
            tokenServer.start();
            log.info("Token server is started.");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
